package rulerouter

import (
	"vpn-management-server/src/controller/rulecontroller"
	"vpn-management-server/src/interceptor/ruleinterceptor"
	"vpn-management-server/src/router/routermodel"
)

var ruleRouter = routermodel.NewRouter()

func init() {
	// 规则 增删查
	ruleRouter.RegisterHandleSet("addRule", ruleinterceptor.RuleValidator, rulecontroller.AddRule, ruleinterceptor.AddRuleLogToChan)
	ruleRouter.RegisterHandleSet("getAllRulesByPage", ruleinterceptor.GetAllRuleValidator, rulecontroller.GetAllRulesByPage, nil)
	ruleRouter.RegisterHandleSet("deleteRules", ruleinterceptor.DeleteRuleValidator, rulecontroller.DeleteRules, ruleinterceptor.DeleteRulesLogToChan)
	// 用户组规则增删查
	ruleRouter.RegisterHandleSet("grantRuleToUGroup", ruleinterceptor.GrantRuleToUGroupValidator, rulecontroller.GrantRuleToUGroup, ruleinterceptor.GrantRuleToUGroupLogToChan)
	ruleRouter.RegisterHandleSet("depriveRuleFromUGroup", ruleinterceptor.DepriveRuleFromUGroupValidator, rulecontroller.DepriveRuleFromUGroup, ruleinterceptor.DepriveRuleFromUGroupLogToChan)
	ruleRouter.RegisterHandleSet("getUGroupRulesByPage", ruleinterceptor.GetUGroupRuleValidator, rulecontroller.GetUGroupRulesByPage, nil)
	//ruleRouter.RegisterHandleSet("userGroupGetRulesByPage", ruleinterceptor.GetUGroupRuleValidator, rulecontroller.UserGroupGetRulesByPage, nil)
	ruleRouter.RegisterHandleSet("deleteUGroupRules", ruleinterceptor.DeleteUGroupRuleValidator, rulecontroller.DeleteUGroupRules, ruleinterceptor.DeleteUGroupRulesLogToChan)
	ruleRouter.RegisterHandleSet("grantRuleToUser", ruleinterceptor.GrantRuleToUserValidator, rulecontroller.GrantRuleToUser, ruleinterceptor.GrantRuleToUserLogToChan)
	ruleRouter.RegisterHandleSet("depriveRuleFromUser", ruleinterceptor.DepriveRuleFromUserValidator, rulecontroller.DepriveRuleFromUser, ruleinterceptor.DepriveRuleFromUserLogToChan)
	ruleRouter.RegisterHandleSet("getUserRuleByPage", ruleinterceptor.GetUserRuleByPageValidator, rulecontroller.GetUserRuleByPage, nil)
	ruleRouter.RegisterHandleSet("getUserRule", ruleinterceptor.GetUserRuleValidator, rulecontroller.GetUserRule, nil)
	ruleRouter.RegisterHandleSet("getRGroupRulesByPage", ruleinterceptor.GetRGroupRulesByPageValidator, rulecontroller.GetRGroupRulesByPage, nil)
	ruleRouter.RegisterHandleSet("getRuleByRuleID", ruleinterceptor.GetRuleByRuleIDValidator, rulecontroller.GetRuleByRuleID, nil)
	ruleRouter.RegisterHandleSet("getAllRuleInfos", nil, rulecontroller.GetAllRuleInfos, nil)
	ruleRouter.RegisterHandleSet("getUGroupRuleInfos", ruleinterceptor.GetUGroupAllRuleInfosValidator, rulecontroller.GetUGroupRuleInfos, nil)
	ruleRouter.RegisterHandleSet("recoverRules", ruleinterceptor.RecoverUGroupRuleValidator, rulecontroller.RecoverRules, ruleinterceptor.RecoverRulesLogToChan)
}
